home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / C++ Toolbox 1.0 / Types++.h < prev   
C/C++ Source or Header  |  1996-03-10  |  1KB  |  45 lines

  1. #pragma once
  2. /*
  3.     File:        Types++.h
  4.     
  5.     Contents:    C++ extensions to the Macintosh toolbox.
  6.     
  7.     Version:    3.7 (for System 7.x)
  8.     
  9.     Copyright:    ©1995 Chris K. Thomas.  All Rights Reserved.
  10. */
  11.  
  12. #ifndef COMPILERHAS_BOOL
  13. #define bool int
  14. #endif
  15.  
  16. #include <Types.h>
  17. #include <TextUtils.h>
  18.  
  19. #ifdef Assert_
  20. #undef Assert_
  21. #endif /*Assert_*/
  22.  
  23. #ifdef Throw_
  24. #undef Throw_
  25. #endif /*Throw_*/
  26.  
  27. #define DEBUGSTR(x) DebugStr("\p" x);    //comment for non-debug behavior
  28.  
  29. #define Assert_(x) if(!(x)) DEBUGSTR("\pAssertion failure: " #x)
  30. #define Throw_(x) do{DEBUGSTR("\pThrowing: " #x); throw x;}while(false)
  31.  
  32. #define check(x) Assert_(x);
  33. #define require(x, y) do {if(!(x)) {DEBUGSTR("\p" #y); goto y;}} while(false)
  34. #define require_action(x, y, action) do {if(!(x)) {DEBUGSTR("\p" #y); action; goto y;}}while(false)
  35.  
  36. // an assert which throws if test is failed.
  37. #define EnforceAssertion_(x) if(!(x)) {DebugStr("\pAssertion failure: " #x); throw 'asrt';}
  38.  
  39. inline void DebugNum(long num)
  40. {
  41.     Str255 value;
  42.     NumToString(num, value);
  43.     DebugStr(value);
  44. }
  45.